package com.sun.showcase.controller.testcase;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sun.showcase.biz.testcase.service.TaskGroupService;
import com.sun.showcase.client.testcase.domain.TaskGroup;
import com.sun.showcase.client.testcase.query.TaskGroupQuery;
import com.sun.showcase.pojo.DataGrid;
import com.sun.showcase.pojo.Json;

@Controller
@RequestMapping(value="/testcase/taskGroup") 
public class TaskGroupController{
	
	@Autowired
	private TaskGroupService taskGroupService;
	
	private Json result = new Json();
	/**
	 * 跳转到TaskGroup管理页面
	 * 
	 * @return
	 */
	@RequestMapping(value="goTaskGroup")
	public String goTaskGroup() {
		return "basic/taskGroup";
	}
	/**
	 * 跳转到TaskGroup新增页面
	 * 
	 * @return
	 */
	@RequestMapping(value="handleTaskGroup")
	public String handleTaskGroup(@RequestParam(value="id",required=false) Long id ,ModelMap map) {
		return "basic/taskGroup_rowEdit";
	}

	/**
	 * 跳转到查看desc页面
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="showDesc")
	public TaskGroup showDesc(TaskGroupQuery taskGroupQuery) {
		return taskGroupService.get(taskGroupQuery);
	}

	/**
	 * 获得分页数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/datagrid")
	public DataGrid datagrid(TaskGroupQuery taskGroupQuery) {
		return taskGroupService.datagrid(taskGroupQuery);
	}
	
	/**
	 * 获得分页数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/listAll")
	public List<TaskGroupQuery> listAll(TaskGroupQuery taskGroupQuery) {
		return taskGroupService.listAll(taskGroupQuery);
	}
	

	/**
	 * 添加一个TaskGroup
	 */
	@ResponseBody
	@RequestMapping(value="add")
	public Json add(TaskGroupQuery taskGroupQuery) {
		taskGroupService.add(taskGroupQuery);
		result.setSuccess(true);
		result.setMsg("添加成功！");
		return result;
	}

	/**
	 * 编辑TaskGroup
	 */
	@ResponseBody
	@RequestMapping(value="edit")
	public Json edit(TaskGroupQuery taskGroupQuery) {
		taskGroupService.update(taskGroupQuery);
		result.setSuccess(true);
		result.setMsg("编辑成功！");
		return result;
	}

	/**
	 * 物理删除TaskGroup
	 */
	@ResponseBody
	@RequestMapping(value="delete")
	public Json delete(TaskGroupQuery taskGroupQuery) {
		taskGroupService.delete(taskGroupQuery.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
	
	/**
	 * 逻辑删除TaskGroup
	 */
	@ResponseBody
	@RequestMapping(value="deletePt")
	public Json deletePt(TaskGroupQuery taskGroupQuery) {
		taskGroupService.deletePt(taskGroupQuery.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
}
